package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.RandomVo;
import com.ruoyi.system.domain.SjRadomStandard;
import com.ruoyi.system.domain.SjStandard;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SjRandomRecord;
import com.ruoyi.system.service.ISjRandomRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 随机记录Controller
 * 
 * @author ruoyi
 * @date 2024-01-04
 */
@RestController
@RequestMapping("/system/recordrandom")
public class SjRandomRecordController extends BaseController
{
    @Autowired
    private ISjRandomRecordService sjRandomRecordService;


    /**
     * 查询随机标准列表
     */
    @PostMapping("/listByRecord")
    public AjaxResult listByRecord(SjRandomRecord sjRandomRecord)
    {
        List<SjStandard> list = sjRandomRecordService.selectSjStandardList(sjRandomRecord);
        return AjaxResult.success("成功",list);
    }

    /**
     * 随机标准
     */
    @Log(title = "双随机标准", businessType = BusinessType.EXPORT)
    @PostMapping("/randomStandardDown")
    public void randomStandardDown(HttpServletResponse response, SjRandomRecord sjRandomRecord)
    {
        List<SjStandard> list = sjRandomRecordService.selectSjStandardList(sjRandomRecord);
        ExcelUtil<SjStandard> util = new ExcelUtil<SjStandard>(SjStandard.class);
        util.exportExcel(response, list, "双随机标准数据");
    }

    /**
     * 查询随机记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:recordrandom:list')")
    @GetMapping("/list")
    public TableDataInfo list(SjRandomRecord sjRandomRecord)
    {
        startPage();
        List<SjRandomRecord> list = sjRandomRecordService.selectSjRandomRecordList(sjRandomRecord);
        return getDataTable(list);
    }

    /**
     * 导出随机记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:recordrandom:export')")
    @Log(title = "随机记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SjRandomRecord sjRandomRecord)
    {
        List<SjRandomRecord> list = sjRandomRecordService.selectSjRandomRecordList(sjRandomRecord);
        ExcelUtil<SjRandomRecord> util = new ExcelUtil<SjRandomRecord>(SjRandomRecord.class);
        util.exportExcel(response, list, "随机记录数据");
    }



    /**
     * 获取随机记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:recordrandom:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sjRandomRecordService.selectSjRandomRecordById(id));
    }

    /**
     * 新增随机记录
     */
    @PreAuthorize("@ss.hasPermi('system:recordrandom:add')")
    @Log(title = "随机记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SjRandomRecord sjRandomRecord)
    {
        return toAjax(sjRandomRecordService.insertSjRandomRecord(sjRandomRecord));
    }

    /**
     * 修改随机记录
     */
    @PreAuthorize("@ss.hasPermi('system:recordrandom:edit')")
    @Log(title = "随机记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SjRandomRecord sjRandomRecord)
    {
        return toAjax(sjRandomRecordService.updateSjRandomRecord(sjRandomRecord));
    }

    /**
     * 删除随机记录
     */
    @PreAuthorize("@ss.hasPermi('system:recordrandom:remove')")
    @Log(title = "随机记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sjRandomRecordService.deleteSjRandomRecordByIds(ids));
    }
}
